import { http } from "@/utils/http";
type ResultTable = {
  pageNum?: number;
  pageSize?: number;
  total?: number;
  pages?: number;
  data?: Array<any>;
};
type ResultComponent = {
  id?: number;
  twinsId?: string;
  twinsName?: string;
  facCode?: string;
  type?: string;
  json?: string;
};

type ResultData = {
  type?: string;
  name?: string;
  attrs?: [
    {
      title: string;
      key: string;
      value: Record<string, any>;
      unit: string;
      icon: string;
      tagNum: string;
      attrSort: number;
      status: string;
    }
  ];
  children?: Array<any>;
  direction?: string;
};
type ResultCommon = {
  [x: string]: any;
  path?: string;
};
export const queryVisualConfigTableData = (data?: object) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/twinsConfig/pageList", { data });
};
export const deleteVisualConfigTableData = (data?: object) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/twinsConfig/delByIds", { data });
};
export const queryVisualConfigTreeData = (data?: object) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/position/queryTree", { data });
};

export const queryAllChildTree = (data?: object) => {
  return http.request<ResultCommon>("post", "/digitaltwins/api/v1/publish/position/queryChildListAllByCode", { data });
};
export const queryFacPositionTree = (data?: object) => {
  return http.request<ResultCommon>("post", "/digitaltwins/api/v1/publish/position/queryFacPositionTree", { data });
};
export const uploadPicArray = (data?: object) => {
  return http.request<ResultTable>(
    "post",
    "/sharing/api/v1/file/uploadImageFiles",
    { data },
    { headers: { "Content-Type": "multipart/form-data;charset=UTF-8" } }
  );
};
export const uploadPicEqp = (data?: object) => {
  return http.request<ResultTable>(
    "post",
    "/digitaltwins/api/v1/visualFacPositionEqp/uploadEqpImages",
    { data },
    { headers: { "Content-Type": "multipart/form-data;charset=UTF-8" } }
  );
};
// export const queryFactoryData = (data?: object) => {
//   return http.request<ResultData>(
//     "post",
//     "/digitaltwins/api/v1/visualization/visualFactory",
//     { data },
//     { headers: { "Content-Type": "application/x-www-form-urlencoded" } }
//   );
// };
export const queryFactoryData = (data?: object) => {
  return http.request<ResultData>("post", "/digitaltwins/api/v1/visualization/visualFactory", { data });
};
export const queryBuildData = (data?: object) => {
  return http.request<ResultData>("post", "/digitaltwins/api/v1/visualization/visualBuilding", { data });
};
export const queryFloorData = (data?: object) => {
  return http.request<ResultData>("post", "/digitaltwins/api/v1/visualization/visualFloor", { data });
};
export const queryRoomData = (data?: object) => {
  return http.request<ResultData>("post", "/digitaltwins/api/v1/visualization/queryByPositionCode", { data });
};
export const saveTemplData = (data?: object) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/twinsConfig/save", { data });
};
export const queryTemplData = (data?: object) => {
  return http.request<ResultComponent>("post", "/digitaltwins/api/v1/twinsConfig/getOne", { data });
};
export const visualqueryById = (data: object) => {
  return http.request("post", `digitaltwins/api/v1/visualization/queryByEquipmentId`, {
    data
  });
};

export const queryEqpId = (data: object) => {
  return http.request<ResultCommon>("post", `digitaltwins/api/v1/equipment/queryByEqpId`, {
    data
  });
};
export const eqpTagLineChart = (data: object) => {
  return http.request<ResultCommon>("post", `digitaltwins/api/v1/visualization/eqpTagLineChart`, {
    data
  });
};
// 柱状图
export const eqpTagBarChart = (data: object) => {
  return http.request<ResultCommon>("post", `digitaltwins/api/v1/visualization/pointBarChart`, {
    data
  });
};
// table列表
export const eqpTagTable = (data: object) => {
  return http.request<ResultCommon>("post", `digitaltwins/api/v1/visualization/detectorList`, {
    data
  });
};
export const copyTwinsConfig = (data: object) => {
  return http.request<ResultCommon>("post", `digitaltwins/api/v1/twinsConfig/copyTwinsConfig`, {
    data
  });
};

//基础树配置相关
//获取基础树
export const queryVisualTree = (data: object) => {
  return http.request<ResultCommon>("post", `digitaltwins/api/v1/visualFacPosition/queryFacPositionTree`, {
    data
  });
};
//保存设备
export const savePositionEqpRelation = (data: object) => {
  return http.request<ResultCommon>("post", `digitaltwins/api/v1/visualFacPositionEqp/savePositionEqpRelation`, {
    data
  });
};
//根据位置code查询关联设备
export const listByPositionCode = (data: object) => {
  return http.request<ResultCommon>("post", `digitaltwins/api/v1/visualFacPositionEqp/queryList`, {
    data
  });
};
//删除设备
export const delById = (id: string) => {
  return http.request<ResultCommon>("post", `digitaltwins/api/v1/visualFacPositionEqp/delById/${id}`);
};
//保存左树
export const visualTreeSave = (data: object) => {
  return http.request<ResultCommon>("post", `/digitaltwins/api/v1/visualFacPosition/save`, {
    data
  });
};
//删除左树
export const delTreeItemById = (data: object) => {
  return http.request<ResultCommon>("post", `digitaltwins/api/v1/visualFacPosition/delByPositionCode`, {
    data
  });
};
//根据位置code查询关联设备
export const delTreeAllEqp = (data: { positionCode: string }) => {
  return http.request<ResultCommon>("post", `digitaltwins/api/v1/visualFacPositionEqp/delByPositionCode/${data.positionCode}`);
};
//根据位置code查询关联设备
export const delTreeItemByIds = data => {
  return http.request<ResultCommon>(
    "post",
    `/digitaltwins/api/v1/visualFacPositionEqp/delByIds
`,
    { data }
  );
};
//根据位置code新增、修改groups
export const groupSaveOrUpdate = data => {
  return http.request<ResultCommon>(
    "post",
    `/digitaltwins/api/v1/equipmentGroup/saveOrUpdate

`,
    { data }
  );
};
//查询设备组列表
export const getGroupList = data => {
  return http.request<ResultCommon>(
    "post",
    `digitaltwins/api/v1/equipmentGroup/pageList
`,
    { data }
  );
};
//删除设备组
export const delGroupItemByNo = (groupNo: string) => {
  return http.request<ResultCommon>(
    "post",
    `/digitaltwins/api/v1/equipmentGroup/delByGroupCode/${groupNo}
`
  );
};
//查询设备组设备列表
export const groupListByPositionCode = data => {
  return http.request<ResultCommon>(
    "post",
    `/digitaltwins/api/v1/equipmentGroup/listByPositionCode
`,
    { data }
  );
};
//查询设备组设备列表
export const addEqpsOnGroup = data => {
  return http.request<ResultCommon>(
    "post",
    `/digitaltwins/api/v1/equipmentGroup/addEqpsOnGroup
`,
    { data }
  );
};
//删除设备组下设备
export const delGrouoItemByIds = data => {
  return http.request<ResultCommon>(
    "post",
    `/digitaltwins/api/v1/equipmentGroup/removeEqpsOnGroup

`,
    { data }
  );
};
//查询摄像头设备列表
export const queryMonitor = data => {
  return http.request<ResultCommon>(
    "post",
    `/digitaltwins/api/v1/monitor/queryList

`,
    { data }
  );
};
//查询报警数量
export const alarmCount = data => {
  return http.request<ResultCommon>("post", `/sharing/api/v1/alarm/count`, { data });
};
//查询room报警数量
export const alarmRoomCount = data => {
  return http.request<ResultCommon>("post", `/digitaltwins/api/v1/visualization/queryAlarmByFloorId`, { data });
};
//查询温湿度
export const queryTempAndHumid = data => {
  return http.request<ResultCommon>("post", `/digitaltwins/api/v1/visualization/queryTempAndHumid`, { data });
};
//基础树配置--更新设备图片
export const syncImg2TwinsConfig = data => {
  return http.request<ResultCommon>(
    "post",
    `/digitaltwins/api/v1/visualFacPositionEqp/syncImg2TwinsConfig
`,
    { data }
  );
};
//判断是否可视化的设备(进行可视化跳转)
export const isVisualEqp = data => {
  return http.request<ResultCommon>(
    "post",
    `/digitaltwins/api/v1/visualFacPositionEqp/isVisualEqp
`,
    { data }
  );
};
//判断是否可视化的设备(进行可视化跳转)
export const queryAttrsByEqpIds = data => {
  return http.request<ResultCommon>("post", `/digitaltwins/api/v1/visualization/queryAttrsByEqpIds`, { data });
};
//判断是否可视化的设备(进行可视化跳转)
export const queryEqpExtendInfo = data => {
  return http.request<ResultCommon>("post", `/digitaltwins/api/v1/visualization/queryEqpExtendInfo`, { data });
};
export const queryByEquipmentIds = (data?: object) => {
  return http.request("post", `/digitaltwins/api/v1/equipmentAttribute/queryByEquipmentId`, {
    data
  });
};
export const queryByGroupEqpIds = (data?: object) => {
  return http.request("post", `/digitaltwins/api/v1/equipmentAttribute/queryByGroupEqpId`, {
    data
  });
};
export const updateEqpConfig = (data?: object) => {
  return http.request("post", `/digitaltwins/api/v1/visualFacPositionEqp/updateEqpConfig`, {
    data
  });
};
export const queryErcAlarmLatestList = (data?: object) => {
  return http.request("post", `/digitaltwins/api/v1/visualization/queryErcAlarmLatestList`, {
    data
  });
};
export const uploadEqpRealImg = (data?: object) => {
  return http.request<ResultTable>(
    "post",
    "/digitaltwins/api/v1/visualFacPositionEqp/uploadEqpRealImg",
    { data },
    { headers: { "Content-Type": "multipart/form-data;charset=UTF-8" } }
  );
};
export const delRealImgName = (data?: object) => {
  return http.request(
    "post",
    `/digitaltwins/api/v1/visualFacPositionEqp/delRealImgName
`,
    {
      data
    }
  );
};
// 可视化--左侧巡检路线
export const queryInspectionList = (data: object) => {
  return http.request("post", `/digitaltwins/api/v1/inspectionRoute/queryList`, {
    data
  });
};
// 可视化--右侧表格
export const queryInspectionItem = (data: object) => {
  return http.request("post", `/digitaltwins/api/v1/inspectionRouteItem/queryList`, {
    data
  });
};
// 可视化基础树配置--查询摄像头列表
export const queryCameraList = (data: object) => {
  return http.request<ResultTable>(
    "post",
    `/digitaltwins/api/v1/monitor/pageList
`,
    {
      data
    }
  );
};
// 可视化基础树配置--摄像头设备保存
export const batchSave = (data: object) => {
  return http.request<ResultTable>("post", `/digitaltwins/api/v1/monitorEqpRelation/batchSave`, {
    data
  });
};
// 可视化基础树配置--摄像头其余保存
export const updateMonitorPosition = (data: object) => {
  return http.request<ResultTable>(
    "post",
    `/digitaltwins/api/v1/monitor/updateMonitorPosition
`,
    {
      data
    }
  );
};
// 可视化基础树配置--查询摄像头关系列表(位置)
export const queryCameraListByPosition = (data: object) => {
  return http.request<ResultTable>(
    "post",
    `/digitaltwins/api/v1/monitor/queryList
`,
    {
      data
    }
  );
};
// 可视化基础树配置--查询摄像头关系列表(设备)
export const queryCameraListById = (data: object) => {
  return http.request<ResultTable>(
    "post",
    `/digitaltwins/api/v1/monitorEqpRelation/queryList
`,
    {
      data
    }
  );
};
// 可视化基础树配置--删除摄像头关系列表(设备)
export const delCameraListByids = (data: object) => {
  return http.request<ResultTable>(
    "post",
    `/digitaltwins/api/v1/monitorEqpRelation/delByIds
`,
    {
      data
    }
  );
};
// 可视化基础树配置--删除摄像头关系列表(位置)
export const delCameraListByPosition = (data: object) => {
  return http.request<ResultTable>(
    "post",
    `/digitaltwins/api/v1/monitor/deleteMonitorPosition
`,
    {
      data
    }
  );
};
//查询业务报警列表
export const queryById = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/sharing/api/v1/alarm/business/query`, {
    data
  });
};
